KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > spi > impl > DataSourceChangeListenerImpl3


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/spi/impl/DataSourceChangeListenerImpl3.java#3 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2005-2007 Julian Hyde
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.spi.impl;
11
12 import mondrian.spi.DataSourceChangeListener;
13 import mondrian.olap.MondrianDef;
14 import mondrian.rolap.RolapHierarchy;
15 import mondrian.rolap.agg.Aggregation;
16
17
18 /**
19  * Default implementation of a data source change listener
20  * that always returns that the datasource is changed.
21  *
22  * A change listener can be specified in the connection string. It is used
23  * to ask what is changed in the datasource (e.g. database).
24  *
25  * Everytime mondrian has to decide whether it will use data from cache, it
26  * will call the change listener. When the change listener tells mondrian
27  * the datasource has changed for a dimension, cube, ... then mondrian will
28  * flush the cache and read from database again.
29  *
30  * It is specified in the connection string, like this :
31  *
32  * <blockquote><code>
33  * Jdbc=jdbc:odbc:MondrianFoodMart; JdbcUser=ziggy; JdbcPassword=stardust; DataSourceChangeListener=com.acme.MyChangeListener;
34  * </code></blockquote>
35  *
36  * This class should be called in mondrian before any data is read, so
37  * even before cache is build. This way, the plugin is able to register
38  * the first timestamp mondrian tries to read the datasource.
39  *
40  * @author Bart Pappyn
41  * @version $Id: //open/mondrian/src/main/mondrian/spi/impl/DataSourceChangeListenerImpl3.java#3 $
42  * @since Dec 12, 2006
43  */

44
45 public class DataSourceChangeListenerImpl3 implements DataSourceChangeListener {
46     
47     /** Creates a new instance of DataSourceChangeListenerImpl2 */
48     public DataSourceChangeListenerImpl3() {
49     }
50
51
52     public synchronized boolean isHierarchyChanged(RolapHierarchy hierarchy) {
53         return true;
54     }
55
56     public synchronized boolean isAggregationChanged(Aggregation aggregation) {
57         return true;
58     }
59
60     public String JavaDoc getTableName(RolapHierarchy hierarchy) {
61         MondrianDef.Relation relation = hierarchy.getRelation();
62         if (relation instanceof MondrianDef.Table) {
63             MondrianDef.Table tableRelation = (MondrianDef.Table)relation;
64
65             return tableRelation.name;
66         } else {
67             return null;
68         }
69     }
70 }
71
Popular Tags