ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc.Heim...@prolifics.de
Subject Re: Using Ibatis as core for an Eclipse SQL plugin
Date Fri, 15 Feb 2008 08:14:48 GMT
We are developing an Eclipse Rich Client project using iBatis and faced 
the same problem.
Our solution is to use the Eclipse Buddy mechanism (see 
http://www.eclipsezone.com/articles/eclipse-vms/ and 
http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/bundle_manifest.html

for details).

We explicitly register our plugins that contain the sqlmaps.
That means in the manifest of the iBatis plugin the buddy entry is 
Eclipse-BuddyPolicy: registered
and in the plugins containing the sqlmaps we have Eclipse-RegisterBuddy: 
com.ibatis

I recon that for your purpose the "dependent" or "global" setting might be 
helpful

HTH
Marc Heimann
Software Engineer

Prolifics Deutschland GmbH
Notkestr. 3, D-22607 Hamburg
phone +49 (0)40 890 667-70
fax    +49 (0)40 890 667-99
marc.heimann@prolifics.de
2007 IBM Award Winner for Overall Technical Excellence
SOA... Building Future Business Solutions Today
Handelsregister: Hamburg, HRB 89903
Geschäftsführer: Ulrich Frotscher


Maarten Meijer <mjmeijer@xs4all.nl> wrote on 14.02.2008 16:55:39:

> 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
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message