[federate-commits] Federate SVN: r23 - in trunk: federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar and 11 other directories.

federate-commits at lists.jboss.org federate-commits at lists.jboss.org
Thu Nov 20 11:12:09 EST 2008


Author: rareddy
Date: 2008-11-19 18:27:38 -0500 (Wed, 19 Nov 2008)
New Revision: 23

Added:
   trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/
   trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/Handler.java
   trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/JarURLConnection.java
Modified:
   trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/MetaMatrixURLStreamHandlerFactory.java
   trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java
   trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java
   trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java
   trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java
   trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java
   trunk/federate-connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java
   trunk/federate-connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
   trunk/federate-connectors/connector-xml/
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/FilteringHTTPSender.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java
   trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java
   trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
   trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
Log:
Packaging in the Federate Embedded has changed, and code in the connectors were written to knowledge that how they were packaged later, which seems wrong. So, converted them to use the context class loader, instead of the "this" classes's class loader.

Modified: trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/MetaMatrixURLStreamHandlerFactory.java
===================================================================
--- trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/MetaMatrixURLStreamHandlerFactory.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/MetaMatrixURLStreamHandlerFactory.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -1,64 +1,67 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2008 Red Hat, Inc.
- * Copyright (C) 2000-2007 MetaMatrix, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor 
- * license agreements.  See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.protocol;
-
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
-
-import com.metamatrix.common.protocol.classpath.ClasspathURLConnection;
-import com.metamatrix.common.protocol.mmfile.MMFileURLConnection;
-import com.metamatrix.common.protocol.mmrofile.MMROFileURLConnection;
-
-
-/** 
- * A factory class for registering the "classpath:" and "mmfile:" protocol based URL.
- * since we can not register in app servers currently this only used for testing.
- * @since 4.4
- */
-public class MetaMatrixURLStreamHandlerFactory implements URLStreamHandlerFactory {
-    private static final String DEFAULT_HANDLER_PKG = "sun.net.www.protocol"; //$NON-NLS-1$
-    
-    public URLStreamHandler createURLStreamHandler(String protocol) {
-        if (protocol.equals(ClasspathURLConnection.PROTOCOL)) {
-            return new com.metamatrix.common.protocol.classpath.Handler();
-        }
-        else if (protocol.equals(MMFileURLConnection.PROTOCOL)) {
-            return new com.metamatrix.common.protocol.mmfile.Handler();
-        }
-        else if (protocol.equals(MMROFileURLConnection.PROTOCOL)) {
-            return new com.metamatrix.common.protocol.mmrofile.Handler();
-        }        
-        else {
-            String handlerName = DEFAULT_HANDLER_PKG+"."+protocol+".Handler"; //$NON-NLS-1$ //$NON-NLS-2$
-            try {
-                Class handlerClass = Class.forName(handlerName);
-                return (URLStreamHandler)handlerClass.newInstance();
-            } catch (Exception e) {    
-                // eat it and return null
-            }
-        }
-        return null;
-    }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2000-2007 MetaMatrix, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor 
+ * license agreements.  See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.common.protocol;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
+import com.metamatrix.common.protocol.classpath.ClasspathURLConnection;
+import com.metamatrix.common.protocol.jar.JarURLConnection;
+import com.metamatrix.common.protocol.mmfile.MMFileURLConnection;
+import com.metamatrix.common.protocol.mmrofile.MMROFileURLConnection;
+
+
+/** 
+ * A facory class for registering the "classpath:" and "mmfile:" protocol based URL.
+ * since we can not register in app servers currently this only used for testing.
+ * @since 4.4
+ */
+public class MetaMatrixURLStreamHandlerFactory implements URLStreamHandlerFactory {
+    private static final String DEFAULT_HANDLER_PKG = "sun.net.www.protocol"; //$NON-NLS-1$
+    
+    public URLStreamHandler createURLStreamHandler(String protocol) {
+        if (protocol.equals(ClasspathURLConnection.PROTOCOL)) {
+            return new com.metamatrix.common.protocol.classpath.Handler();
+        }
+        else if (protocol.equals(MMFileURLConnection.PROTOCOL)) {
+            return new com.metamatrix.common.protocol.mmfile.Handler();
+        }
+        else if (protocol.equals(MMROFileURLConnection.PROTOCOL)) {
+            return new com.metamatrix.common.protocol.mmrofile.Handler();
+        }        
+        else if (protocol.equals(JarURLConnection.PROTOCOL)) {
+            return new com.metamatrix.common.protocol.jar.Handler();
+        }           
+        else {
+            String handlerName = DEFAULT_HANDLER_PKG+"."+protocol+".Handler"; //$NON-NLS-1$ //$NON-NLS-2$
+            try {
+                Class handlerClass = Class.forName(handlerName);
+                return (URLStreamHandler)handlerClass.newInstance();
+            } catch (Exception e) {    
+                // eat it and return null
+            }
+        }
+        return null;
+    }
+}

Added: trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/Handler.java
===================================================================
--- trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/Handler.java	                        (rev 0)
+++ trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/Handler.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2000-2007 MetaMatrix, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor 
+ * license agreements.  See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.common.protocol.jar;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+
+/** 
+ * URL Stream Handler class for resources in a given classpath 
+ */
+public class Handler extends URLStreamHandler {
+    protected URLConnection openConnection(URL u) throws IOException {
+        return new JarURLConnection(u);
+    }
+}


Property changes on: trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/Handler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/JarURLConnection.java
===================================================================
--- trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/JarURLConnection.java	                        (rev 0)
+++ trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/JarURLConnection.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -0,0 +1,269 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2000-2007 MetaMatrix, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor 
+ * license agreements.  See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.common.protocol.jar;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.cert.Certificate;
+import java.util.HashMap;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
+import com.metamatrix.common.protocol.URLHelper;
+import com.metamatrix.common.protocol.mmfile.MMFileURLConnection;
+
+
+/** 
+ * Jar protocol connection class. The class extends the JDK provided JarURLConnection factory.
+ * However Jar protocol can not understand the federate specific protocols like mmfile, mmrofile etc.
+ * The issue is if you can register application specific protocols during start-up 
+ * using system properties the bulit in JAR protocol understands those protocols. 
+ * However in the Federate model this need to work by just dropping in in any 
+ * container. This handler will be called for any class loaders registered 
+ * with {@link MetaMatrixURLStreamHandlerFactory}, so that they understand the application specific protocols.   
+ */
+public class JarURLConnection extends java.net.JarURLConnection {
+    
+    public static String PROTOCOL = "jar"; //$NON-NLS-1$
+    public static URL DUMMY_URL = null;
+    URL jarFileURL = null;
+    String jarEntry = null;
+    private static HashMap jarMap = new HashMap();
+    
+    static {
+        try {            
+            DUMMY_URL = new URL(PROTOCOL, "", -1, "file:/dummy.foo!/"); //$NON-NLS-1$ //$NON-NLS-2$
+        } catch (MalformedURLException e) {
+            // ignore
+        }
+    }
+    
+    /** 
+     * @param url
+     * @throws MalformedURLException
+     * @since 4.3
+     */
+    protected JarURLConnection(URL url) throws MalformedURLException {
+        // This super class is trying to construct a new URL() with out using the
+        // URLHelper, and thus not finding the custom protocol handlers and exiting 
+        // before rest of the construction, by throwing exception. this trick is to
+        // avoid it. All the public class methods have been overridden in this class
+        // such that all the base classes's functionality is duplicated, and base class
+        // is just for marker interface (which JVM should have made as interface)
+        super(DUMMY_URL);       
+
+        // This is one line for which this whole jar protocol handler has been 
+        // created.
+        String path = url.getPath();
+        int index = path.indexOf("!/"); //$NON-NLS-1$
+        if (index != -1) {
+            // This is where the jar file can be found
+            jarFileURL = URLHelper.buildURL(path.substring(0, index));            
+        }
+        
+        // this what somebody may be looking for as resource
+        if (path.length() > (index+2)) {
+            jarEntry = path.substring(index+2);
+        }
+    }
+
+    /**  
+     * @see java.net.JarURLConnection#getJarFileURL()
+     */
+    public URL getJarFileURL() {
+        return jarFileURL;
+    }
+    
+    /** 
+     * @see java.net.URLConnection#connect()
+     * @since 4.3
+     */
+    public void connect() throws IOException {
+        connected = true;
+    }
+
+       
+    public synchronized JarFile getJarFile() throws java.io.IOException {
+        if (!connected) {
+            connect();
+        }
+
+        // make sure do input not set to false
+        if (!doInput) {
+            throw new ProtocolException("Can not open JarFile if doInput is false"); //$NON-NLS-1$
+        }
+        
+        JarFile jarFile = null;
+        
+        // get the Jar file URL
+        URL jarFileURL = getJarFileURL();
+        String protocol = jarFileURL.getProtocol();
+        
+        // if we are using the file based protocol then use the same
+        // file as the jar file; otherwise persist to temp loacation and use it.        
+        if ((protocol.equals("file") || protocol.equals(MMFileURLConnection.PROTOCOL)) ) { //$NON-NLS-1$
+            jarFile = new JarFile(jarFileURL.getPath());
+        } 
+        else {
+            jarFile = (JarFile)jarMap.get(jarFileURL);
+            if (jarFile == null) {                
+                URLConnection urlconn = jarFileURL.openConnection();
+                InputStream is = urlconn.getInputStream();
+                
+                // create temporary directory for metamatrix
+                File tempDirectory = new File(System.getProperty("mm.io.tmpdir")); //$NON-NLS-1$ 
+                if (!tempDirectory.exists()) {
+                    tempDirectory.mkdirs();
+                }
+                
+                // stream the data in and create a temp file
+                byte[] buf = new byte[4 * 1024];  
+                File f = File.createTempFile("dqp", ".jar", tempDirectory); //$NON-NLS-1$ //$NON-NLS-2$
+                FileOutputStream fos = new FileOutputStream(f);
+                int len = 0;
+                while ((len = is.read(buf)) != -1) {
+                    fos.write(buf, 0, len);
+                }
+                fos.close();
+                is.close();
+
+                // Using the temp file create the jar file
+                jarFile = new JarFile(f, true, ZipFile.OPEN_READ);                
+                jarMap.put(jarFileURL, jarFile);
+                f.deleteOnExit();
+            }            
+        }
+        return jarFile;
+    }
+
+    /** 
+     * @see java.net.URLConnection#getInputStream()
+     * @since 4.3
+     */
+    public InputStream getInputStream() throws IOException {
+        if (!connected) {
+            connect();
+        }
+
+        // make sure we have valid flags
+        if (!doInput) {
+            throw new ProtocolException("Can not open InputStream if doInput is set to false"); //$NON-NLS-1$
+        }
+
+        // make sure we user requested for valid entry
+        if (jarEntry == null || jarEntry.length() == 0) {
+            throw new IOException("Entry name requested in the "+url+ " is wrong"); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        
+        // now get the jar file, and look for the entry and return
+        // stream to the resource.
+        JarFile jarFile = getJarFile();
+        ZipEntry entry = jarFile.getEntry(jarEntry);
+        if (entry != null) {
+            return jarFile.getInputStream(entry);
+        }        
+        return null;
+    }
+    
+    
+    public int getContentLength() {
+        if (!connected) {
+            return -1;
+        }
+        
+        try {
+            JarFile jarFile = getJarFile();
+            ZipEntry entry = jarFile.getEntry(jarEntry);
+            if (entry != null) {
+                return (int)entry.getSize();
+            }
+        } catch (IOException e) {
+            //eat it.
+        }
+        
+        return -1;
+    }
+
+    /** 
+     * @see java.net.JarURLConnection#getAttributes()
+     * @since 4.3
+     */
+    public Attributes getAttributes() throws IOException {
+        JarEntry e = getJarEntry();
+        return e != null ? e.getAttributes() : null;
+    }
+
+    /** 
+     * @see java.net.JarURLConnection#getCertificates()
+     * @since 4.3
+     */
+    public Certificate[] getCertificates() throws IOException {
+        JarEntry e = getJarEntry();
+        return e != null ? e.getCertificates() : null;
+    }
+
+    /** 
+     * @see java.net.JarURLConnection#getEntryName()
+     * @since 4.3
+     */
+    public String getEntryName() {
+        return jarEntry;
+    }
+
+    /** 
+     * @see java.net.JarURLConnection#getJarEntry()
+     * @since 4.3
+     */
+    public JarEntry getJarEntry() throws IOException {
+        return getJarFile().getJarEntry(jarEntry);
+    }
+
+    /** 
+     * @see java.net.JarURLConnection#getMainAttributes()
+     * @since 4.3
+     */
+    public Attributes getMainAttributes() throws IOException {
+        Manifest man = getManifest();
+        return man != null ? man.getMainAttributes() : null;
+    }
+
+    /** 
+     * @see java.net.JarURLConnection#getManifest()
+     * @since 4.3
+     */
+    public Manifest getManifest() throws IOException {
+        return getJarFile().getManifest();
+    }    
+}


Property changes on: trunk/federate-common-internal/src/main/java/com/metamatrix/common/protocol/jar/JarURLConnection.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -74,7 +74,7 @@
         
         logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_initialized._1")); //$NON-NLS-1$
         
-        capabilities = createCapabilities(environment, this.getClass().getClassLoader()); 
+        capabilities = createCapabilities(environment, Thread.currentThread().getContextClassLoader()); 
     }
 
 	static ConnectorCapabilities createCapabilities(ConnectorEnvironment environment, ClassLoader loader)
@@ -127,7 +127,7 @@
 
             try {
                 //create source connection factory
-                Class scfClass = this.getClass().getClassLoader().loadClass(scfClassName);
+                Class scfClass = Thread.currentThread().getContextClassLoader().loadClass(scfClassName);
                 this.factory = (JDBCSourceConnectionFactory) scfClass.newInstance();
                 factory.initialize(environment);
                 

Modified: trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java
===================================================================
--- trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -71,7 +71,7 @@
         this.connectionStrategy = connectionStrategy;
         this.connectionListener = connectionListener;
         try {
-            ClassLoader loader = this.getClass().getClassLoader();
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
             Properties connectorProps = environment.getProperties();
             //create SQLTranslator

Modified: trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java
===================================================================
--- trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -75,7 +75,8 @@
             throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_driver_class_name_1")); //$NON-NLS-1$
         }
         try {
-            return (Driver) Class.forName(driverClassName).newInstance();
+        	Class clazz = Thread.currentThread().getContextClassLoader().loadClass(driverClassName);
+            return (Driver) clazz.newInstance();
         } catch(Exception e) {
             throw new ConnectorException(e, JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Unable_to_load_the_JDBC_driver_class_6", driverClassName)); //$NON-NLS-1$
         }

Modified: trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java
===================================================================
--- trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -107,7 +107,8 @@
         // create data source
         final DataSource baseDs;
         try {
-            baseDs = (DataSource) Class.forName(dataSourceClassName).newInstance();
+        	Class clazz = Thread.currentThread().getContextClassLoader().loadClass(dataSourceClassName);
+            baseDs = (DataSource) clazz.newInstance();
         } catch(Exception e) {
             throw new ConnectorException(e,JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Unable_to_load_the_JDBC_driver_class_6", dataSourceClassName)); //$NON-NLS-1$
         }

Modified: trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java
===================================================================
--- trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -107,7 +107,7 @@
             
             try {
                 //create xa source connection factory
-                Class scfClass = this.getClass().getClassLoader().loadClass(scfClassName);
+                Class scfClass = Thread.currentThread().getContextClassLoader().loadClass(scfClassName);
                 SourceConnectionFactory factory = (SourceConnectionFactory) scfClass.newInstance();           
 
                 appEnvProps.setProperty(XAJDBCPropertyNames.IS_XA, Boolean.TRUE.toString());

Modified: trunk/federate-connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java
===================================================================
--- trunk/federate-connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -55,7 +55,8 @@
     void loadCapabilities(String capabilityClass, ConnectorLogger logger) {
         if(capabilityClass != null && capabilityClass.length() > 0) {
             try {
-                capabilities = (ConnectorCapabilities) Class.forName(capabilityClass).newInstance();
+            	Class clazz = Thread.currentThread().getContextClassLoader().loadClass(capabilityClass);
+                capabilities = (ConnectorCapabilities) clazz.newInstance();
                 logger.logInfo("Loaded " + capabilityClass + " for LoopbackConnector"); //$NON-NLS-1$ //$NON-NLS-2$
             } catch(ClassNotFoundException cnfe) {
                 logger.logError("Capabilities class not found: " + capabilityClass, cnfe); //$NON-NLS-1$

Modified: trunk/federate-connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- trunk/federate-connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -60,7 +60,8 @@
 			String capabilitiesClass = env.getProperties().getProperty("ConnectorCapabilities");
 			if(capabilitiesClass != null) {
 	        	try {
-	        		salesforceCapabilites = (SalesforceCapabilities) Class.forName(capabilitiesClass).newInstance();
+	        		Class clazz = Thread.currentThread().getContextClassLoader().loadClass(capabilitiesClass);
+	        		salesforceCapabilites = (SalesforceCapabilities) clazz.newInstance();
 				} catch (Exception e) {
 					throw new ConnectorException(e, "Unable to load Capabilities Class");
 				}


Property changes on: trunk/federate-connectors/connector-xml
___________________________________________________________________
Name: svn:ignore
   - .classpath

target

.settings

.project

   + .classpath

target

.settings

.project

devnull

cache


Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -80,8 +80,9 @@
 	private XMLConnectorState createState(ConnectorEnvironment env) throws ConnectorException {		
 		String stateClassName = env.getProperties().getProperty(XMLConnectorState.STATE_CLASS_PROP);
 		XMLConnectorState state = null;
-		try {
-			state = (XMLConnectorState) Class.forName(stateClassName).newInstance();
+		try {
+			Class clazz = Thread.currentThread().getContextClassLoader().loadClass(stateClassName);
+			state = (XMLConnectorState) clazz.newInstance();
 			state.setLogger(this.getLogger());
 			state.setState(env);
 		} catch (Exception e) {

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -155,7 +155,7 @@
 				
 				InputStream filter = null;
 				try {
-					Class pluggableFilter = Class.forName(getState().getPluggableInputStreamFilterClass());
+					Class pluggableFilter = Thread.currentThread().getContextClassLoader().loadClass(getState().getPluggableInputStreamFilterClass());
 					Constructor ctor = pluggableFilter.getConstructor(
 							new Class[] { java.io.InputStream.class, com.metamatrix.data.api.ConnectorLogger.class});
 					filter = (InputStream) ctor.newInstance(new Object[] {response, logger});

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -85,8 +85,9 @@
 	 */
     public TrustedPayloadHandler getTrustDeserializerInstance() throws ConnectorException {
     	Object secObj;
-		try {
-			secObj = Class.forName(getSecurityDeserializerClass()).newInstance();
+		try {
+			Class clazz = Thread.currentThread().getContextClassLoader().loadClass(getSecurityDeserializerClass());
+			secObj = clazz.newInstance();
 		} catch (Exception e) {
 			String message = Messages.getString("SecureConnectorStateImpl.error.loading.trust.deserializer");
 			throw new ConnectorException(e, message);

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -26,6 +26,7 @@
 package com.metamatrix.connector.xml.base;
 
 import java.util.Properties;
+
 import com.metamatrix.connector.xml.IQueryPreprocessor;
 import com.metamatrix.connector.xml.SAXFilterProvider;
 import com.metamatrix.connector.xml.XMLConnectorState;
@@ -217,8 +218,8 @@
             String connectorCapabilitiesClass) throws ConnectorException {
         ConnectorCapabilities caps = null;
         try {
-            caps = (ConnectorCapabilities) Class.forName(
-                    connectorCapabilitiesClass).newInstance();
+        	Class clazz = Thread.currentThread().getContextClassLoader().loadClass(connectorCapabilitiesClass);
+            caps = (ConnectorCapabilities) clazz.newInstance();
         } catch (Exception e) {
             logger.logError(e.getMessage(), e);
             throw new ConnectorException(e);
@@ -494,8 +495,8 @@
             throws ConnectorException {
         IQueryPreprocessor pre = null;
         try {
-            pre = (IQueryPreprocessor) Class.forName(queryPreprocessorClass)
-                    .newInstance();
+        	Class clazz = Thread.currentThread().getContextClassLoader().loadClass(queryPreprocessorClass);
+            pre = (IQueryPreprocessor) clazz.newInstance();
         } catch (Exception e) {
             logger.logError(e.getMessage(), e);
             throw new ConnectorException(e);
@@ -511,8 +512,8 @@
             throws ConnectorException {
         SAXFilterProvider filter = null;
         try {
-            filter = (SAXFilterProvider) Class.forName(SAXFilterClass)
-                    .newInstance();
+        	Class clazz = Thread.currentThread().getContextClassLoader().loadClass(SAXFilterClass);
+            filter = (SAXFilterProvider) clazz.newInstance();
         } catch (Exception e) {
             logger.logError(e.getMessage(), e);
             throw new ConnectorException(e);

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -181,7 +181,7 @@
 		
 		InputStream filter = null;
     	try {
-    		Class pluggableFilter = Class.forName(m_state.getPluggableInputStreamFilterClass());
+    		Class pluggableFilter = Thread.currentThread().getContextClassLoader().loadClass(m_state.getPluggableInputStreamFilterClass());
     		Constructor ctor = pluggableFilter.getConstructor(
     				new Class[] { java.io.InputStream.class, com.metamatrix.data.api.ConnectorLogger.class});
     		filter = (InputStream) ctor.newInstance(new Object[] {response, logger});

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -158,7 +158,8 @@
         setHostnameVerifierClassName(props.getProperty(HOSTNAME_VERIFIER));
         if(getHostnameVerifierClassName() != null) {
         	try {
-				HostnameVerifier verifier = (HostnameVerifier) Class.forName(getHostnameVerifierClassName()).newInstance();
+        		Class clazz = Thread.currentThread().getContextClassLoader().loadClass(getHostnameVerifierClassName());
+				HostnameVerifier verifier = (HostnameVerifier) clazz.newInstance();
 				HttpsURLConnection.setDefaultHostnameVerifier(verifier);
 			} catch (Exception e) {
 				throw new ConnectorException(e, "Unable to load HostnameVerifier");

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/FilteringHTTPSender.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/FilteringHTTPSender.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/FilteringHTTPSender.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -29,7 +29,7 @@
 			result = new LoggingInputStreamFilter(result, logger);
 		}
 		
-		Class pluggableFilter = Class.forName(state.getPluggableInputStreamFilterClass());
+		Class pluggableFilter = Thread.currentThread().getContextClassLoader().loadClass(state.getPluggableInputStreamFilterClass());
 		Constructor ctor = pluggableFilter.getConstructor(
 			new Class[] { java.io.InputStream.class, com.metamatrix.data.api.ConnectorLogger.class});
 		result = (InputStream) ctor.newInstance(new Object[] {result, logger});

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -120,7 +120,8 @@
         setHostnameVerifierClassName(props.getProperty(HTTPConnectorState.HOSTNAME_VERIFIER));
         if(getHostnameVerifierClassName() != null) {
         	try {
-				HostnameVerifier verifier = (HostnameVerifier) Class.forName(getHostnameVerifierClassName()).newInstance();
+        		Class clazz = Thread.currentThread().getContextClassLoader().loadClass(getHostnameVerifierClassName());
+				HostnameVerifier verifier = (HostnameVerifier) clazz.newInstance();
 				HttpsURLConnection.setDefaultHostnameVerifier(verifier);
 			} catch (Exception e) {
 				throw new ConnectorException(e, "Unable to load HostnameVerifier");

Modified: trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java
===================================================================
--- trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -58,7 +58,7 @@
         throws ConnectorException {
         String connectionTypeClass = env.getProperties().getProperty("ConnectionType"); //$NON-NLS-1$
         try {
-            Class clazz = Class.forName(connectionTypeClass);
+            Class clazz = Thread.currentThread().getContextClassLoader().loadClass(connectionTypeClass);
             Constructor c = clazz.getConstructor(new Class[] {ConnectorEnvironment.class});                       
             XMLSourceConnection conn = (XMLSourceConnection)c.newInstance(new Object[] {this.env});
             return conn;

Modified: trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
===================================================================
--- trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -71,7 +71,7 @@
         this.logger = environment.getLogger();
         
         try {
-            ClassLoader loader = this.getClass().getClassLoader();
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
             
             this.capabilities = ObjectConnectorUtil.createCapabilities(environment, loader);
             

Modified: trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
===================================================================
--- trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java	2008-11-19 20:43:53 UTC (rev 22)
+++ trunk/federate-connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java	2008-11-19 23:27:38 UTC (rev 23)
@@ -70,7 +70,7 @@
 //        }
         
         try {
-            ClassLoader loader = this.getClass().getClassLoader();
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
             factory = ObjectConnectorUtil.createFactory(this.env, loader);
 //            String scfClassName = env.getProperties().getProperty(ObjectPropertyNames.EXT_CONNECTION_FACTORY_CLASS);  //$NON-NLS-1$




More information about the federate-commits mailing list