首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

对schema文件修改后不需要重启workbench的解决办法

2012-11-16 
对schema文件修改后不需要重启workbench的解决方法在使用mondrian的workbench进行schema文件设计的时候,由

对schema文件修改后不需要重启workbench的解决方法
在使用mondrian的workbench进行schema文件设计的时候,由于workbench会对打开的schema文件进行缓存,所以在每次修改完schema文件后,都需要重新启动workbench才能保证在进行MDX query时得到正确的处理结果.这对于开发和测试来说就显得非常的不方便了.通过查找mondrian GUI的源代码,最终找到了解决的方法:当在mdx query查询界面中点击"connect"按钮时,将mondrian缓存中的缓存信息清除,重新创建一个连接,这样就可以达到修改schema文件后不需要重启workbench的目的了.
具体的源码修改过程如下:
在类mondrian.gui.QueryPanel中找到connectButton的事件处理函数connectButtonActionPerformed(),找到获取连接的代码

Connection con = DriverManager.getConnection(connectString, null);
在其上面增加下面的代码
if(evt != null){// 由于这个方法会在打开query界面的时候被调用,增加这个判断是为了保证是在单击过connectButton之后才进行缓存的清理            LOGGER.debug("dinguangx:remove the cache.>connectionstring ->"+connectString+"");            PropertyList property = Util.parseConnectString(connectString);            String jdbcUser = SchemaUtil.getJdbcUser(property);            String connectionKey = SchemaUtil.getConnectionKey(property);            String catalogUrl = SchemaUtil.getCatalogUrl(property);            String strDataSource = SchemaUtil.getStrDataSource(property);            new CacheControlImpl().flushSchema(catalogUrl,connectionKey,jdbcUser, strDataSource);            }        //end.            Connection con = DriverManager.getConnection(connectString, null);

其中用到了一个类是SchemaUtil,这个类中的代码是从mondrian的源代码中提取出来的,整个SchemaUtil类的代码如下:
public class SchemaUtil {        public static String getConnectionKey(PropertyList pl){String jdbcConnectString = pl.get(RolapConnectionProperties.Jdbc.name());String connectionKey = jdbcConnectString+getJdbcProperties(pl).toString();return connectionKey;}public static String getJdbcUser(PropertyList pl){return pl.get(RolapConnectionProperties.JdbcUser.name());}public static String getStrDataSource(PropertyList pl){return pl.get(RolapConnectionProperties.DataSource.name());}public static String getCatalogUrl(PropertyList pl){return pl.get(RolapConnectionProperties.Catalog.name());}private static Properties getJdbcProperties(Util.PropertyList connectInfo){Properties jdbcProperties = new Properties();for (Pair<String, String> entry : connectInfo){if (entry.left.startsWith(RolapConnectionProperties.JdbcPropertyPrefix)){jdbcProperties.put(entry.left.substring(RolapConnectionProperties.JdbcPropertyPrefix.length()), entry.right);}}return jdbcProperties;}}

热点排行