ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Using Ibatis as core for an Eclipse SQL plugin
Date Thu, 14 Feb 2008 16:41:26 GMT
Calling setDefaultClassLoader should work.  It's not used on the method you
mention because you pass in a specific class loader.  So, call
setDefaultClassLoader before you do anything, then call the method overloads
that do not take a classloader as a parm - getResourceAsStream(String).

If no specific classloader is passed in, then iBATIS will use the default
class loader if one exists, or the thread context classloader.  This method
is the method used to load sqlMap files listed in the sqlMapConfig (unless
you list them by URL).

Confusing enough?

Jeff Butler

On Thu, Feb 14, 2008 at 9:55 AM, Maarten Meijer <mjmeijer@xs4all.nl> wrote:

> Hi,
>
> I'm working on Eclipse Mylyn bug 184532: [connector] Generic SQL
> connector
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=184532
>
> As I have some experience with Ibatis as database connection for a
> servlet I try to use it here again.
> Benefits of ibatis for this bug:
> The XML configurable SQL result sets makes it possible to map from
> almost any accessible database to the Mylyn task model.
>
> I've succeeded in opening the SqlMapConfix.xml with parameters in a
> properties file using the following code:
>
> public class TasksSqlMapConfig {
>        private static SqlMapClient sqlMap = null;
>
>        public static SqlMapClient getSqlMapInstance() throws CoreException
> {
>                if (null == sqlMap) {
>                        try {
>                                InputStream resource = null;
>                                Path mapPath = new
> Path("maps/SqlMapConfig.xml");
>                                resource =
> FileLocator.openStream(IbatisCorePlugin.getDefault().getBundle(),
> mapPath, false);
>                                // replace with read from pref later
>                                Path propPath = new
> Path("maps/db.properties");
>                                InputStream propStream =
> FileLocator.openStream(IbatisCorePlugin.getDefault().getBundle(),
> propPath,
>                                                false);
>                                Properties properties = new Properties();
>                                properties.load(propStream);
>
>                                sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(resource,
> properties);
>                        } catch (Exception e) {
>                                Status init = new Status(IStatus.ERROR,
> IbatisCorePlugin.PLUGIN_ID, "Could not initialize SqlMaps", e);
>                                StatusHandler.log(init);
>                                throw new CoreException(init);
>                        }
>                }
>                return sqlMap;
>        }
>
>        private TasksSqlMapConfig() {
>                super();        // Singleton
>        }
> }
>
> This will start to parse the XML alright and use the properties as
> replacement. However when it is time to locate the Sqlmap.xml files
> referenced in the SqlMapConfig.xml an error occurs. Eclipse bundles
> all have their own class path so maybe ibatis has problems locating
> the resource.
>
> Is it possible to insert a replacement or additional class loader?
> I've tries using Resources.setDefaultClassLoader but this isn't used
> anywhere,
> likecom
> .ibatis.common.resources.Resources.getResourceAsStream(ClassLoader,
> String)
>
> Is this option fully implemented? Is there a tutorial available, I
> have "Ibaqtis in Action" but haven't found anything.
>
>

Mime
View raw message