1 10 11 package org.mule.providers.soap.xfire; 12 13 import java.util.List ; 14 15 import org.apache.commons.pool.BasePoolableObjectFactory; 16 import org.codehaus.xfire.XFire; 17 import org.codehaus.xfire.handler.Handler; 18 import org.codehaus.xfire.transport.Transport; 19 import org.codehaus.xfire.client.Client; 20 import org.codehaus.xfire.service.Service; 21 import org.mule.config.MuleProperties; 22 import org.mule.umo.endpoint.UMOEndpointURI; 23 import org.mule.umo.endpoint.UMOImmutableEndpoint; 24 import org.mule.providers.soap.xfire.transport.MuleUniversalTransport; 25 26 public class XFireClientPoolFactory extends BasePoolableObjectFactory 27 { 28 29 protected UMOEndpointURI uri; 30 protected Service service; 31 protected XFire xfire; 32 protected XFireConnector connector; 33 34 public XFireClientPoolFactory(UMOImmutableEndpoint endpoint, Service service, XFire xfire) 35 { 36 super(); 37 uri = endpoint.getEndpointURI(); 38 connector = (XFireConnector)endpoint.getConnector(); 39 this.service = service; 40 this.xfire = xfire; 41 } 42 43 public Object makeObject() throws Exception 44 { 45 Class transportClazz; 46 if(connector.getClientTransport() == null) 47 transportClazz = MuleUniversalTransport.class; 48 else 49 transportClazz = Class.forName(connector.getClientTransport()); 50 51 Transport transport = (Transport)transportClazz.getConstructor(null).newInstance(null); 52 Client client = new Client(transport, service, uri.toString()); 53 client.setXFire(xfire); 54 client.setEndpointUri(uri.toString()); 55 client.addInHandler(new MuleHeadersInHandler()); 56 client.addOutHandler(new MuleHeadersOutHandler()); 57 58 List inList = connector.getClientInHandlers(); 59 if(inList != null) 60 { 61 for(int i = 0; i < inList.size(); i++) 62 { 63 Class clazz = Class.forName(inList.get(i).toString()); 64 Handler handler = (Handler)clazz.getConstructor(null).newInstance(null); 65 client.addInHandler(handler); 66 } 67 } 68 69 List outList = connector.getClientOutHandlers(); 70 if(outList != null) 71 { 72 for(int i = 0; i < outList.size(); i++) 73 { 74 Class clazz = Class.forName(outList.get(i).toString()); 75 Handler handler = (Handler)clazz.getConstructor(null).newInstance(null); 76 client.addOutHandler(handler); 77 } 78 } 79 return client; 80 } 81 82 public void passivateObject(Object obj) throws Exception 83 { 84 ((Client)obj).removeProperty(MuleProperties.MULE_EVENT_PROPERTY); 85 super.passivateObject(obj); 86 } 87 88 } 89 | Popular Tags |