1 57 58 package com.myeis.wsif.providers.j2c.myeis; 59 60 import javax.resource.*; 61 import javax.resource.cci.*; 62 import javax.wsdl.*; 63 import javax.wsdl.Binding; 64 import javax.wsdl.extensions.*; 65 66 import java.util.Iterator ; 67 import java.util.List ; 68 69 import com.myeis.j2c.*; 70 import com.myeis.wsdl.extensions.j2c.myeis.*; 71 import org.apache.wsif.*; 72 import org.apache.wsif.base.*; 73 import org.apache.wsif.providers.jca.*; 74 import org.apache.wsif.providers.jca.WSIFUtils_JCA; 75 import org.apache.wsif.providers.*; 76 77 public class WSIFProvider_MyEIS implements org.apache.wsif.spi.WSIFProvider, org.apache.wsif.providers.jca.WSIFProviderJCAExtensions { 78 79 private final String [] namespaces = {MyEISBindingConstants.NS_URI}; 80 81 84 public WSIFProvider_MyEIS() { 85 super(); 86 WSIFServiceImpl.addExtensionRegistry(new MyEISExtensionRegistry()); 87 } 88 89 92 public WSIFPort createDynamicWSIFPort(Definition definition, Service service, Port port, WSIFDynamicTypeMap typeMap) throws WSIFException { 93 94 WSIFPort_JCA jcaPort = null; 95 Connection connection = null; 96 ConnectionFactory connectionFactory = null; 97 98 Binding binding = port.getBinding(); 99 List eElements = binding.getExtensibilityElements(); 100 Iterator iterator = eElements.iterator(); 101 while (iterator.hasNext()) { 102 Object o = iterator.next(); 103 if (o instanceof MyEISBinding) { 104 109 String res_ref_name = WSIFUtils_JCA.getJNDILookupName(service, port); 110 connectionFactory = WSIFUtils_JCA.lookupConnectionFactory(res_ref_name, "javax.resource.cci.ConnectionFactory"); 111 112 try { 113 ExtensibilityElement portExtension = (ExtensibilityElement) port.getExtensibilityElements().get(0); 114 115 if (portExtension == null) { 116 return jcaPort; 117 } 118 MyEISAddress address = (MyEISAddress) portExtension; 119 if (connectionFactory == null) { 120 124 MyEISManagedConnectionFactory managedConnectionFactory = new MyEISManagedConnectionFactory(); 125 managedConnectionFactory.setRepositoryLocation(address.getRepositoryLocation()); 126 connectionFactory = (ConnectionFactory) managedConnectionFactory.createConnectionFactory(); 127 } 128 connection = connectionFactory.getConnection(); 129 } 130 catch(Throwable exn){ 131 return jcaPort; 132 } 133 jcaPort = new WSIFPort_JCA(definition, service, port, connection, this, typeMap); 134 return jcaPort; 135 136 } 137 } 138 return jcaPort; 139 } 140 141 142 public WSIFMessage createInputMessage(Definition definition, Binding binding, String operationName, String inputName, String outputName){return null;} 143 public WSIFMessage createOutputMessage(Definition definition, Binding binding, String operationName, String inputName, String outputName){return null;} 144 public WSIFMessage createFaultMessage(Definition definition, Binding binding, String operationName, String inputName, String outputName){return null;} 145 146 public String [] getBindingNamespaceURIs(){ 147 return namespaces; 148 } 149 150 public String [] getAddressNamespaceURIs(){ 151 return namespaces; 152 } 153 public void updateOutputMessage(WSIFMessage output, Binding aBinding, String aOperationName, String aInputName, String aOutputName, InteractionSpec aInteractionSpec) { 154 } 156 public void updateInteractionSpec(WSIFMessage input, Binding aBinding, String aOperationName, String aInputName, String aOutputName, InteractionSpec aInteractionSpec) { 157 } 159 160 161 164 public Connection createConnection( 165 WSIFMessage input, 166 Definition definition, 167 Service service, 168 Port port, 169 WSIFDynamicTypeMap typeMap, 170 Binding aBinding, 171 String aOperationName, 172 String aInputName, 173 String aOutputName) 174 throws WSIFException { 175 return null; 176 } 177 178 181 public WSIFOperation createOperation( 182 Definition aDefinition, 183 Service aService, 184 Port aPort, 185 String aOperationName, 186 String aInputName, 187 String aOutputName, 188 WSIFDynamicTypeMap typeMap, 189 WSIFPort_JCA jcaPort, 190 Connection aConnection) 191 throws WSIFException { 192 WSIFOperation_JCA operation = null; 193 194 try { 195 BindingOperation bindingOperationModel = aPort.getBinding().getBindingOperation(aOperationName, aInputName, aOutputName); 196 197 ExtensibilityElement bindingOperationModelExtension = (ExtensibilityElement) bindingOperationModel.getExtensibilityElements().get(0); 198 if (bindingOperationModelExtension == null) { 199 throw new WSIFException("missing bindingOperation extension"); 200 } 201 if (!(bindingOperationModelExtension instanceof MyEISOperation)) { 202 throw new WSIFException("invalid extensibility element"); 203 } 204 205 MyEISOperation operationModelExtension = (MyEISOperation) bindingOperationModelExtension; 206 207 MyEISInteractionSpec interactionSpec = new MyEISInteractionSpec(); 208 interactionSpec.setFunctionName(operationModelExtension.getFunctionName()); 209 210 operation = new WSIFOperation_JCA(aDefinition, aService, aPort, aOperationName, aInputName, aOutputName, typeMap, jcaPort, this, aConnection, interactionSpec); 211 } 212 catch (Exception e) { 213 e.printStackTrace(); 214 } 215 216 return operation; 217 } 218 219 } | Popular Tags |