1 57 58 59 package org.apache.wsif.providers.jca; 60 61 import java.net.MalformedURLException ; 62 import java.net.URL ; 63 import java.util.ArrayList ; 64 import java.util.Iterator ; 65 import java.util.List ; 66 import java.util.StringTokenizer ; 67 68 import javax.naming.*; 69 import javax.resource.cci.ConnectionFactory ; 70 import javax.wsdl.*; 71 import javax.wsdl.Binding; 72 import javax.wsdl.extensions.ExtensibilityElement; 73 74 import org.apache.wsif.util.WSIFUtils; 75 import org.apache.wsif.wsdl.extensions.format.TypeMapping; 76 import org.apache.wsif.format.WSIFFormatHandler; 77 78 79 84 85 86 public class WSIFUtils_JCA extends WSIFUtils{ 87 88 private static final long serialVersionUID = 1L; 89 private static final String DOT = "."; 90 private static final String lookupPrefix = "java:comp/env/"; 91 private static final String emptyString = ""; 92 93 102 public static String getJNDILookupName(Service service, Port port) { 103 104 String jndiName = getPackageNameFromNamespaceURI(service.getQName().getNamespaceURI()); 105 if(!jndiName.endsWith(DOT)) 106 jndiName = jndiName + DOT; 107 jndiName = jndiName.replace('.', '/'); 108 jndiName = jndiName + WSIFUtils_JCA.getJavaNameFromXMLName(service.getQName().getLocalPart()); 109 jndiName = jndiName + WSIFUtils_JCA.getJavaNameFromXMLName(port.getName()); 110 return jndiName; 111 112 } 113 114 115 116 125 public static ConnectionFactory lookupConnectionFactory(String res_ref_name, String res_type){ 126 127 ConnectionFactory connectionFactory = null; 128 Context ctx = null; 129 try { 130 ctx = new InitialContext(); 132 if (ctx == null) { 133 return null; 134 } 135 connectionFactory = (ConnectionFactory ) ctx.lookup(lookupPrefix + res_ref_name); 136 137 if (connectionFactory == null) { 138 throw new NamingException(); 139 } 140 141 try { 143 if (!(Class.forName(res_type, false, Thread.currentThread().getContextClassLoader()).isInstance(connectionFactory))) { 144 return null; 145 } 146 } 147 catch (ClassNotFoundException exn5) { 148 return null; 149 } 150 151 ctx.close(); 152 } 153 catch (NamingException exn2) { 154 try { 155 if (ctx == null) { 156 return null; 157 } 158 connectionFactory = (ConnectionFactory ) ctx.lookup(res_ref_name); 160 161 if (connectionFactory == null) { 162 return null; 163 } 164 try { 166 if (!(Class.forName(res_type, false, Thread.currentThread().getContextClassLoader()).isInstance(connectionFactory))) { 167 return null; 168 } 169 } 170 catch (ClassNotFoundException exn5) { 171 return null; 172 } 173 ctx.close(); 174 } 175 catch (NamingException exn3) { 176 return null; 177 } 178 } 179 return connectionFactory; 180 } 181 182 } 183 | Popular Tags |